package student.test.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import student.test.DAO.UsersDAO;
import student.test.entity.User;
@Controller
public class LoginController {
    @Autowired
    private UsersDAO usersDAO;
    @GetMapping("/login.html")
    public String index(){
        return "login";
    }
    @PostMapping("/login")
    public String login(String userName, String password){
        User u = new User();
        u.setUserName(userName);
        u.setPassword(password);
        if (usersDAO.verify(u)){
            return  "index.html";

        }else{
            return  "login";
        }
    }
}
